import request from '@/utils/request'

var datas = [{id:1,name:'a'},{id:2,name:'b'}];;
export async  function   getRoomList() {
  let res =  await request({
    url: '/Rooms',
    method: 'get',
  })
  return res.data.value;
}
export async function updateRoom(room){
  let res =  await request({
    url: `/Rooms(${room.Id})`,
    method: 'put',
    data: room
  })
  return res.data.value;
}
export async function addRoom(room){
  //
  console.log(JSON.stringify(room));
  let res =  await request({
    url: '/Rooms',
    method: 'post',
    data: room,
  })
  return res.data;
  //
  // return  new Promise(  (resolve, reject) => {
  //   var id = datas[datas.length-1].id+1;
  //   var temp= {id:id,name:roomName}
  //   datas.push(temp);
  //   resolve(temp);
  // });
}
export function removeRoom(id){
  return request({
    url: `/rooms/${id}`,
    method: 'delete',
  })
  // return  new Promise( async (resolve, reject) => {
  //   var index = datas.findIndex(e=>e.id==id);
  //   datas.splice(index,1);
  //   resolve();
  // });


}
